package com.kfm.jdbc.day0330;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Demo02 {

    public static void main(String[] args) {
        try(FileReader reader = new FileReader("d:\\io\\buffered-reader.txt");
            BufferedReader br = new BufferedReader(reader);
        ){
//            String s = null;
//            while( (s = br.readLine()) != null){
//                System.out.println(s);
//            }

//            System.out.println(br.markSupported());
//            String s1 = br.readLine();
//            System.out.print(s1); // 床前明月光，
//            br.mark(100);
//            String s2 = br.readLine();
//            System.out.print(s2); // 疑是地上霜。
//            String s3 = br.readLine();
//            System.out.println(s3); // 举头望明月，
//            br.reset();
//            String s4 = br.readLine();
//            System.out.println(s4); // 疑是地上霜。

            char[] chars = new char[2];
            int len = 0;
            while( (len = br.read(chars)) != -1){
                String s = new String(chars, 0, len);
                if ("举头".equals(s)){
                    System.out.println("标记");
                    br.mark(100);
                }
                System.out.print(s);
            }

            System.out.println();
            System.out.println("=============");
            br.reset();
            while ( (len = br.read(chars)) != -1){
                String s = new String(chars, 0, len);
                System.out.print(s);
            }


        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
